package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName：CityEntity
 * ChineseName：行政区域市（地区）类
 */
@Component("cityEntity")
@Entity
@Table(name = "T_City", schema = "crebas", catalog = "")
public class CityEntity {
    private String pkTCityId;
    private String cityName;
    private String cityPhoneticcode;

    private ProvinceEntity provinceEntity;//省（直辖市）

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "pk_t_province_id")
    public ProvinceEntity getProvinceEntity() {
        return provinceEntity;
    }

    public void setProvinceEntity(ProvinceEntity provinceEntity) {
        this.provinceEntity = provinceEntity;
    }

    @Id
    @Column(name = "pk_t_city_id", nullable = false, length = 5)
    public String getPkTCityId() {
        return pkTCityId;
    }

    public void setPkTCityId(String pkTCityId) {
        this.pkTCityId = pkTCityId;
    }

    @Basic
    @Column(name = "city_name", nullable = false, length = 30)
    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    @Basic
    @Column(name = "city_phoneticcode", nullable = false, length = 100)
    public String getCityPhoneticcode() {
        return cityPhoneticcode;
    }

    public void setCityPhoneticcode(String cityPhoneticcode) {
        this.cityPhoneticcode = cityPhoneticcode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CityEntity that = (CityEntity) o;

        if (pkTCityId != null ? !pkTCityId.equals(that.pkTCityId) : that.pkTCityId != null) return false;
        if (cityName != null ? !cityName.equals(that.cityName) : that.cityName != null) return false;
        return cityPhoneticcode != null ? cityPhoneticcode.equals(that.cityPhoneticcode) : that.cityPhoneticcode == null;

    }

    @Override
    public int hashCode() {
        int result = pkTCityId != null ? pkTCityId.hashCode() : 0;
        result = 31 * result + (cityName != null ? cityName.hashCode() : 0);
        result = 31 * result + (cityPhoneticcode != null ? cityPhoneticcode.hashCode() : 0);
        return result;
    }
}
